package hr.ctg.domain.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.validator.NotNull;

@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "prognoza")
@NamedQueries( {
		@NamedQuery(name = "Prognoza.findLastByNazivMjesta", query = "select p from Prognoza p where p.mjesto.naziv = ? order by dan desc"),
		@NamedQuery(name = "Prognoza.findLastByIdMjesta", query = "select p from Prognoza p where p.mjesto.idMjesta = ? order by dan desc"),
		@NamedQuery(name = "Prognoza.findByMjestoDan", query = "select p from Prognoza p where p.mjesto = ? and p.dan = ?") })
public class Prognoza implements Serializable {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id_prognoze")
	private Integer idPrognoze;

	@Column(name = "min_temperatura")
	private Float minTemperatura;

	@Column(name = "max_temperatura")
	private Float maxTemperatura;

	private Date dan;

	private String kod;

	@Column(name = "datum_objave")
	private Date datumObjave;

	@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_mjesta", nullable = false)
	@NotNull
	private Mjesto mjesto;

	private static final long serialVersionUID = 1L;

	public Prognoza() {
		super();
	}

	public Integer getIdPrognoze() {
		return idPrognoze;
	}

	public void setIdPrognoze(final Integer idPrognoze) {
		this.idPrognoze = idPrognoze;
	}

	public Float getMinTemperatura() {
		return minTemperatura;
	}

	public void setMinTemperatura(final Float minTemperatura) {
		this.minTemperatura = minTemperatura;
	}

	public Float getMaxTemperatura() {
		return maxTemperatura;
	}

	public void setMaxTemperatura(final Float maxTemperatura) {
		this.maxTemperatura = maxTemperatura;
	}

	public Date getDan() {
		return dan;
	}

	public void setDan(final Date dan) {
		this.dan = dan;
	}

	public String getKod() {
		return kod;
	}

	public void setKod(final String kod) {
		this.kod = kod;
	}

	public Date getDatumObjave() {
		return datumObjave;
	}

	public void setDatumObjave(final Date datumObjave) {
		this.datumObjave = datumObjave;
	}

	public Mjesto getMjesto() {
		return mjesto;
	}

	public void setMjesto(final Mjesto mjesto) {
		this.mjesto = mjesto;
	}

}
